<template>
    <div>
        <h3>当前最新的count:{{$store.state.count}}</h3>
        <h4>{{$store.getters.showNum}}</h4>
        <h4>{{showNum}}</h4>
        <button @click="plus">+1</button>
        <button @click="plusN(3)">+3</button>
        <button @click="PlusNAsync(5,2000)">异步+5</button>
        <button @click="storePlusNAsync1({step:6,time:1000})">异步+6</button>
    </div>
</template>

<script>
    import {mapActions} from 'vuex'
    import {mapGetters} from 'vuex'
    export default {
        name: "plus",
        methods:{
            plus:function(){
                this.$store.commit('storePlus')
            },
            plusN:function(n){
                this.$store.commit('storePlusN',n)
            },
            PlusNAsync:function(n,time){
                //只能传2个参数
                this.$store.dispatch('storePlusNAsync',{step:n,time:time})
            },
            ...mapActions(['storePlusNAsync1']),

        },
        computed:{
            ...mapGetters(['showNum'])
        }
    }
</script>

<style scoped>

</style>